import { Directive, ElementRef, HostListener, Input, OnInit } from '@angular/core';

@Directive({ selector: '[qkPermission]' })
export class QkPermissionDirective implements OnInit {
    @Input('qkCode') qkCode: string;

    constructor(private el: ElementRef) { }

    ngOnInit(): void {
        let qkPremissions = localStorage.getItem("resources");
        if (!qkPremissions) this.el.nativeElement.style.display = 'none';
        //仅在有配置权限的情况下才显示
        if ($.inArray(this.qkCode, qkPremissions.split(",")) != -1) {
            this.el.nativeElement.style.display = 'block';
        }
        localStorage.removeItem("resPremission");
    }
}